package com.yuanfengerp.basicInfoManage.addressBase.controller;

import com.yuanfengerp.basicInfoManage.addressBase.model.AddressLibrary;
import com.yuanfengerp.basicInfoManage.addressBase.servicer.impl.IAddressServiceImpl;
import com.yuanfengerp.publicUtil.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Map;

@RestController
@CrossOrigin
public class AddressController {
    @Autowired
    private IAddressServiceImpl iAddressServiceImpl;

    /**
     * 查询所有地址接口
     * @param params // 查询条件
     * @return // 返回结果
     */
    @PostMapping("/selectAllAddress")
    public Result selectAllAddress(@RequestBody Map<String , Object > params){
        return iAddressServiceImpl.selectAllAddress(params);
    }

    /**
     * 新增地址接口
     * @param addressLibrary // 新增地址
     * @return // 返回结果
     */
    @PostMapping("/insertAddress")
    public Result<AddressLibrary> insertAddress(@RequestBody AddressLibrary addressLibrary){
        return iAddressServiceImpl.insertAddress(addressLibrary);
    }
    /**
     * 根据地址名称查询地址接口
     * @param addressLibraryID // 地址名称
     * @return // 返回结果
     */
    @PostMapping("/selectAddressByName")
    public Result<AddressLibrary> selectAddressById(@RequestBody String addressLibraryID){
        return iAddressServiceImpl.selectAddressById(addressLibraryID);
    }

    /**
     * 修改地址接口
     * @param addressLibrary // 修改地址
     * @return // 返回结果
     */
    @PostMapping("/updateAddress")
    public Result<AddressLibrary> updateAddress(@RequestBody AddressLibrary addressLibrary){
        return iAddressServiceImpl.updateAddress(addressLibrary);
    }
}
